package model
{
  import flash.display.*;
  import flash.events.*;
  import flash.net.*;

  // Demonstrates the code required to load external XML
  public class XMLLoader extends Sprite {
    // The variable to which the loaded XML will be assigned
    private var pieces:XML;
    // The object used to load the XML
    private var urlLoader:URLLoader;

    // Constructor
    public function XMLLoader (  ) {
      var urlRequest:URLRequest = new URLRequest("images/pieces.xml");
      urlLoader = new URLLoader(  );
      // Register to be notified when the XML finishes loading
      urlLoader.addEventListener(Event.COMPLETE, completeListener);
      // Load the XML
      urlLoader.load(urlRequest);
    }

    // Method invoked automatically when the XML finishes loading
    private function completeListener(e:Event):void {
      pieces = new XML(urlLoader.data);
    }
    
    public function getData():XML{
    	return this.pieces;
    }
  }
}